﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace Golf.WebUI.AdminShow.OrderManagement
{
    public partial class Golf_OrderProductAdd : Golf.WebUI.App_code.ValidateLogin
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (!PageValidate.IsNumber(txtOrderId.Text))
            {
                strErr += "订单id	Golf_Order格式错误！\\n";
            }
            if (this.txtOrderNumber.Text.Trim().Length == 0)
            {
                strErr += "订单号不能为空！\\n";
            }
            if (!PageValidate.IsNumber(txtUserId.Text))
            {
                strErr += "会员id	Golf_User表格式错误！\\n";
            }
            if (this.txtFristName.Text.Trim().Length == 0)
            {
                strErr += "会员名称	Golf_User表不能为空！\\n";
            }
            if (this.txtLastName.Text.Trim().Length == 0)
            {
                strErr += "会员名称	Golf_User表不能为空！\\n";
            }
            if (!PageValidate.IsNumber(txtProductTypeId.Text))
            {
                strErr += "产品分类id	Golf_Pro格式错误！\\n";
            }
            if (!PageValidate.IsNumber(txtProductId.Text))
            {
                strErr += "产品id	Golf_Produ格式错误！\\n";
            }
            if (this.txtProductName.Text.Trim().Length == 0)
            {
                strErr += "产品名称	Golf_Produ不能为空！\\n";
            }
            if (this.txtGiftId.Text.Trim().Length == 0)
            {
                strErr += "赠品id不能为空！\\n";
            }
            if (!PageValidate.IsNumber(txtGiftNumber.Text))
            {
                strErr += "赠品数量格式错误！\\n";
            }
            if (!PageValidate.IsDecimal(txtProductPrice.Text))
            {
                strErr += "产品单价格式错误！\\n";
            }
            if (!PageValidate.IsNumber(txtBuyNumber.Text))
            {
                strErr += "购买数量格式错误！\\n";
            }
            if (!PageValidate.IsNumber(txtIntegral.Text))
            {
                strErr += "产品积分格式错误！\\n";
            }
            if (this.txtPro_Specification.Text.Trim().Length == 0)
            {
                strErr += "产品规格不能为空！\\n";
            }
            if (!PageValidate.IsNumber(txtAdminId.Text))
            {
                strErr += "后台管理人id	Golf_Ad格式错误！\\n";
            }
            if (!PageValidate.IsDateTime(txtAddTime.Text))
            {
                strErr += "添加生成时间格式错误！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int OrderId = int.Parse(this.txtOrderId.Text);
            string OrderNumber = this.txtOrderNumber.Text;
            int UserId = int.Parse(this.txtUserId.Text);
            string FristName = this.txtFristName.Text;
            string LastName = this.txtLastName.Text;
            int ProductTypeId = int.Parse(this.txtProductTypeId.Text);
            int ProductId = int.Parse(this.txtProductId.Text);
            string ProductName = this.txtProductName.Text;
            string GiftId = this.txtGiftId.Text;
            int GiftNumber = int.Parse(this.txtGiftNumber.Text);
            decimal ProductPrice = decimal.Parse(this.txtProductPrice.Text);
            int BuyNumber = int.Parse(this.txtBuyNumber.Text);
            int Integral = int.Parse(this.txtIntegral.Text);
            string Pro_Specification = this.txtPro_Specification.Text;
            int AdminId = int.Parse(this.txtAdminId.Text);
            DateTime AddTime = DateTime.Parse(this.txtAddTime.Text);

            Golf.Model.Golf_OrderProduct model = new Golf.Model.Golf_OrderProduct();
            model.OrderId = OrderId;
            model.OrderNumber = OrderNumber;
            model.UserId = UserId;
            model.FristName = FristName;
            model.LastName = LastName;
            model.ProductTypeId = ProductTypeId;
            model.ProductId = ProductId;
            model.ProductName = ProductName;
            model.GiftId = GiftId;
            model.GiftNumber = GiftNumber;
            model.ProductPrice = ProductPrice;
            model.BuyNumber = BuyNumber;
            model.Integral = Integral;
            model.Pro_Specification = Pro_Specification;
            model.AdminId = AdminId;
            model.AddTime = AddTime;

            Golf.BLL.Golf_OrderProduct bll = new Golf.BLL.Golf_OrderProduct();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "add.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}